const path = require('path');
const http = require('http');
const express = require('express');
const cookieParser = require('cookie-parser');
const multer = require('multer');
const cors = require('cors')

const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
const downloadRouter = require('./routes/download');
const uploadRouter = require('./routes/upload');
const blobRouter = require('./routes/blob');

const app = express();

app.use(multer({dist: './upload/'}).any());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(cors())

app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/download', downloadRouter);
app.use('/upload', uploadRouter);
app.use('/blob', blobRouter);

http.createServer(app).listen(3000)